import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'
import dataManageRouter from './modules/dataManage'
import panoramaManageRouter from './modules/panoramaManage'

Vue.use(Router)
/* Layout */
export const constantRoutes = [
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path*',
                component: () => import('@/views/redirect/index')
            }
        ]
    },
    {
        path: '/404',
        component: () => import('@/views/errorPage/404'),
        hidden: true
    },
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    {
        path: '',
        component: Layout,
        redirect: 'dashboard',
        children: [
            {
                path: 'dashboard',
                component: () => import('@/views/dashboard/index'),
                name: 'Dashboard',
                meta: { title: '首页', icon: 'export', noCache: true, affix: true }
            }
        ]
    },
    dataManageRouter,
    // dataManageRouter,
    panoramaManageRouter
    // {
    //     path: '/guide',
    //     component: Layout,
    //     redirect: '/guide/index',
    //     children: [
    //         {
    //             path: 'index',
    //             component: () => import('@/views/guide/index'),
    //             name: 'Guide',
    //             meta: { title: 'guide', icon: 'import', noCache: true }
    //         }
    //     ]
    // }
]
export const asyncRoutes = [
    // {
    //     path: '/documentation',
    //     component: Layout,
    //     children: [
    //         {
    //             path: 'index',
    //             component: () => import('@/views/documentation/index'),
    //             name: 'Documentation',
    //             meta: { title: 'documentation', icon: 'inform', affix: true }
    //         }
    //     ]
    // },
    // {
    //     path: '/tab',
    //     component: Layout,
    //     children: [
    //         {
    //             path: 'index',
    //             component: () => import('@/views/tab/index'),
    //             name: 'Tab',
    //             meta: { title: 'tab', icon: 'txt', roles: ['admin'] }
    //         }
    //     ]
    // }
]
const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})
const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}
export default router